<script type ="text/javascript" src="<?php echo $this->baseUrl() ?>/js/vietuni.js" ></script>
<script type ="text/javascript" src="<?php echo $this->baseUrl() ?>/js/tiny_mce/jquery.tinymce.js" ></script>
<script type ="text/javascript" src="<?php echo $this->baseUrl() ?>/js/jquery/ajaxfileupload.js" ></script>
<script type="text/javascript">
$().ready(function() {
        $('textarea.tinymce').tinymce({
                // Location of TinyMCE script
                script_url : '<?php echo $this->baseUrl() ?>/js/tiny_mce/tiny_mce.js',

                // General options
                theme : "advanced",
                plugins : "pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,advlist",

                // Theme options
                theme_advanced_buttons1 : "save,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
                theme_advanced_buttons2 : "cut,copy,paste|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
                theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
                theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak",
                theme_advanced_toolbar_location : "top",
                theme_advanced_toolbar_align : "left",
                theme_advanced_statusbar_location : "bottom",
                theme_advanced_resizing : true

        });
});
</script>
<div class ="insert_title">Nhập bài viết mới  </div>
<div class ="type_style">
    <label for ="off_type" style ="display: inline">
        <input id ="off_type" type=radio name="switcher" value="OFF" checked onFocus="setTypingMode(0)" class="text">
    Off
    </label>
    <label for ="telex_type" style ="display: inline">
    <input id ="telex_type" type=radio name="switcher" value="TELEX" onFocus="setTypingMode(1)" class="text">
    Telex
    </label>
    <label for ="vni_type" style ="display: inline">
    <input id ="vni_type" type=radio name="switcher" value="VNI" onFocus="setTypingMode(2)" class="text">
    VNI  </label>
</div>
<br/>
<?php if ($this->message) : ?>
    <div class ="error">
        <?php foreach ($this->message as $msg) : ?>
        <?php echo $msg; ?> <br/>
        <?php endforeach ?>
    </div>
<?php endif ?>
<form action ="<?php echo $this->baseUrl()?>/article/insert" method ="post">
<div id ="insert_com">
<div class ="content_area">
    <div class ="title_input">
        <div class ="label_input">Chủ đề *</div>
        <div class ="form_input">
            <select name ="tpid">
            <?php foreach ($this->groupAndTopic as $group) : ?>
                <option value ="" class ="none_select"><?php echo $group['name']?></option>
                <?php foreach ($group['topics'] as $topic) :?>
                    <?php
                    $select = "";
                    if (isset($this->data['tpid']) && $this->data['tpid'] == $topic['id']) $select = ' selected = "selected"';
                    ?>
                    <option class ="select_topic" value ="<?php echo $topic['id']?>" <?php echo $select ?>>&nbsp; &nbsp; <?php echo $topic['name']?></option>
                <?php endforeach ?>
            <?php endforeach ?>
            </select>
        </div>
        <div class ="clear"> </div>
    </div>

    <div class ="title_input">
        <div class ="label_input">Tiêu đề *</div>
        <div class ="form_input">
            <input id ="title" type ="text" onkeyup="initTyper(this);"  name ="title" value ="<?php if (isset($this->data['title'])) echo $this->data['title'] ?>" />
        </div>
        <div class ="clear"> </div>
    </div>

    <div class ="insert_content">
        <strong>Nội dung *</strong>
    </div>
    <div class ="title_content">
            <textarea cols ="75" class="tinymce" onkeyup="initTyper(this);"  rows ="20" name = "content"><?php if (isset($this->data['content'])) echo $this->data['content'] ?></textarea>
    </div>
    <div class ="title_input">
        <div class ="label_input">Link gốc</div>
        <div class ="form_input">
            <input type ="text" name ="root_link" value ="<?php if (isset($this->data['root_link'])) echo $this->data['root_link'] ?>" />
        </div>
        <div class ="clear"> </div>
    </div>
    <!--
    <div class ="title_input">
        <div class ="label_input">Đánh tags</div>
        <div class ="form_input">
            <input type ="text" onkeyup="initTyper(this);"  name ="tags" value ="<?php if (isset($this->data['tags'])) echo $this->data['tags'] ?>" />
            (cách nhau bởi dầu phẩy ',')
        </div>
        <div class ="clear"> </div>
    </div>
    -->
    <div class ="insert_submit">
        <input type ="submit" name ="submit" value ="Nhập" />
    </div>
</div>
<div class ="upload_area" style ="margin-top: 100px">
        <div class ="upload_file_title">Tải file cùng bài viết:</div>
        <div class ="upload_file_content" id ="upload_content">
            <?php if ($this->listUploadFiles) : ?>
                <?php foreach ($this->listUploadFiles as $uFile) : ?>
                 <div class ="each_upload_file">
                    <a target ="_blank" href = "<?php echo $uFile->file_path ?>">
                        <span><img width = "42" height = "34" border = "0" src = "<?php echo $uFile->icon_path ?>" /></span>
                        <span><?php echo $uFile->file_name ?></span>
                    </a>
                 </div>
                <?php endforeach ?>
            <?php endif ?>
        </div>

        <div class ="upload_area">
            <img id="loading" src="loading.gif" style="display:none;">
            <form name="form" action="" method="POST" enctype="multipart/form-data">
                <div class ="file_title">File:</div>
                <div class ="file_input">
                    <input id="fileToUpload" type="file" size="15" name="fileToUpload" class="input" />
                    <input type ="hidden" name ="insert_token" value ="<?php echo $this->insertToken?>" />
                </div>
                <div class ="clear"> </div>
                <div class ="file_title">Tên File:</div>
                <div class ="file_input">
                    <input type ="text" size ="10" style ="max-width: 130px;" value ="" name ="file_name" />
                </div>
                <div class ="clear"> </div>
                <div class ="file_submit">
                    <button class="button small blue" id="buttonUpload" onclick="return ajaxFileUpload();">Upload</button>
                </div>
            </form>
        </div>
    </div>
    <div class ="clear"> </div>
</div>
</form>